package com.software.seakdream.service;

import com.software.seakdream.entity.*;
import com.software.seakdream.repository.WhiteNoiseRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;
import java.util.UUID;

@Service
public class WhiteNoiseServiceImpl implements WhiteNoiseService {
    @Autowired
    private WhiteNoiseRepository whiteNoiseRepository;
//    @Override
//    public List<FreeConbination> findAllFreeConbination() {
//        List<FreeConbination> freeConbinations = whiteNoiseRepository.findAllFreeConbination();
//        return freeConbinations;
//    }

    @Override
    public List<AudioInfo> findAllFreeConbination(String type) {

        List<AudioInfo> audioInfos = whiteNoiseRepository.findAllFreeConbination(type);
        return audioInfos;
    }

    @Override
    public List<AudioInfo> findFreeConbinationById(String selectedId1,String selectedId2,String selectedId3) {
        List<AudioInfo> audioInfos = whiteNoiseRepository.findFreeConbinationById(selectedId1,selectedId2,selectedId3);
        return audioInfos;
    }

    @Override
    public List<SleepFriendCreation> findAllSleepFriendCreation() {
        List<SleepFriendCreation> sleepFriendCreations = whiteNoiseRepository.findAllSleepFriendCreation();
        return  sleepFriendCreations;
    }

    @Override
    public List<UserInfo> findAllUser() {
        List<UserInfo> userInfos = whiteNoiseRepository.findAllUser();
        return  userInfos;
    }

    @Override
    public UserInfo findUserInfoById(String userId) {
        UserInfo userInfo = whiteNoiseRepository.findUserInfoById(userId);
        return  userInfo;
    }

    @Override
    public List<OfficialRecommendation> findAllOfficialRecommendation() {
        List<OfficialRecommendation> officialRecommendations = whiteNoiseRepository.findAllOfficialRecommendation();
        return  officialRecommendations;
    }

    @Override
    public String  addSleepFriendCreation(SleepFriendCreation sleepFriendCreation) {
        sleepFriendCreation.setPostTime(new Date());
        whiteNoiseRepository.addSleepFriendCreation(sleepFriendCreation);
        return "ok";
    }

    @Override
    public List<VoiceRemark> findVoiceRemarkBySleepId(String sleepFriendId) {
        List<VoiceRemark> voiceRemarks = whiteNoiseRepository.findVoiceRemarkBySleepId(sleepFriendId);
        return voiceRemarks;
    }

    @Override
    public String addVoiceRemark(VoiceRemark voiceRemark) {
        voiceRemark.setPostTime(new Date());
        voiceRemark.setId(UUID.randomUUID().toString());
        whiteNoiseRepository.addVoiceRemark(voiceRemark);
        return "ok";
    }

    @Override
    public void createHistory(History history) {
        whiteNoiseRepository.createHistory(history);
    }

    @Override
    public void deleteHistory(History history) {
        whiteNoiseRepository.deleteHistory(history);
    }
}
